package com.xujc.controller;

import com.opensymphony.xwork2.ActionSupport;
import com.xujc.dao.IDiscusDAO;
import com.xujc.dao.IFormDAO;
import com.xujc.entity.DiscuseEntity;
import com.xujc.entity.FormEntity;
import org.apache.struts2.interceptor.ParameterAware;

import java.util.List;
import java.util.Map;

/**
 * Created by xujc on 6/20/15.
 */
public class FormAction extends ActionSupport implements ParameterAware{
    private Map<String,String[]> mParameter;
    private IDiscusDAO mDiscusDAO;
    private List<DiscuseEntity> mDiscuses;
    private IFormDAO mFormDAO;
    private FormEntity mForm;


    @Override
    public String execute() throws Exception {
        int fid = Integer.parseInt(mParameter.get("fid")[0]);
        mForm = mFormDAO.getFormById(fid);
        return SUCCESS;
    }

    public FormEntity getForm() {
        return mForm;
    }

    public void setForm(FormEntity form) {
        mForm = form;
    }

    public List<DiscuseEntity> getDiscuses() {
        return mDiscuses;
    }

    public void setDiscuses(List<DiscuseEntity> discuses) {
        this.mDiscuses = discuses;
    }

    public void setDiscusDAO(IDiscusDAO discusDAO) {
        mDiscusDAO = discusDAO;
    }


    public void setFormDAO(IFormDAO formDAO) {
        mFormDAO = formDAO;
    }

    @Override
    public void setParameters(Map<String, String[]> map) {
        mParameter=map;
    }
}
